#include <stdio.h>
#include <time.h>
#include <math.h>

clock_t start , stop;
double duration1,duration2;//秒

void add1(long n)
{
    start=clock();
    long sum=0;
    sum=(1+n)*n/2;
    stop=clock();
    printf("高斯法：从1到%ld的连续整数和为:%ld\n",n,sum);//输出不是计算过程，所以放在外面
    duration1 = ((double)(stop-start))/CLOCKS_PER_SEC;
    printf("高斯法的用时是%f秒\n",duration1);
}

void add2(long n)
{
    start=0;
    stop=0;
    start=clock();
    long sum=0;
    for(int i=1;i<=n;i++)
    {
        sum=i+sum;
    }
   stop=clock();
    printf("累加法：从1到%ld的连续整数和为:%ld\n",n,sum);
    duration2 = ((double)(stop-start))/CLOCKS_PER_SEC;
    printf("累加法的用时是%f秒\n",duration2);
}

int main()
{
    long n;
    scanf("%ld",&n);
    add1(n);
    add2(n);
    return 0;
}
